<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Readxml extends MX_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 * 	- or -
	 * 		http://example.com/index.php/welcome/index
	 * 	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function Readxml() {
		parent::__construct();
	}
	public function index() {
		$doc = new DOMDocument();
		$doc->load('http://devbeta.asiaesolutions.com/services/api/Course/Get');
		$arrFeeds = array();
		foreach ($doc->getElementsByTagName('Course') as $node) {
			$itemRSS = array (
					'CPDType' => $node->getElementsByTagName('CPDType')->item(0)->nodeValue,                
					'CPD_Points' => $node->getElementsByTagName('CPD_Points')->item(0)->nodeValue,
					'ClosingDate' => $node->getElementsByTagName('ClosingDate')->item(0)->nodeValue,
					'CourseDate' => $node->getElementsByTagName('CourseDate')->item(0)->nodeValue,
					'CourseEndDate' => $node->getElementsByTagName('CourseEndDate')->item(0)->nodeValue,
					'Course_ID' => $node->getElementsByTagName('Course_ID')->item(0)->nodeValue,
					'Course_Topics' => $node->getElementsByTagName('Course_Topics')->item(0)->nodeValue,
					'LecturerName' => $node->getElementsByTagName('LecturerName')->item(0)->nodeValue,
					'Register' => $node->getElementsByTagName('Register')->item(0)->nodeValue,
					'TotalSeats' => $node->getElementsByTagName('TotalSeats')->item(0)->nodeValue,
					'Venue' => $node->getElementsByTagName('Venue')->item(0)->nodeValue
			);
			array_push($arrFeeds, $itemRSS);
		}

		echo "<pre>"; print_r($arrFeeds); die();
	}

	public function sum ()
	{
		$x = $this->uri->segment(3);
		$y = $this->uri->segment(4);
		$result = $this->AddSum($x, $y);
		 
		$dom = new DOMDocument;
		 
		$root = $dom->createElement('result', null);
		 
		$dom->appendChild($root);
		 
		$value = $dom->createElement('value', $result);
		$root->appendChild($value);
		 
		echo $dom->saveXML();
	}

	public function AddSum($a, $b) {
		return $a + $b;
	}

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */